package com.chexiehui.jc.ui.activity;

import android.os.Bundle;
import android.widget.EditText;

import com.aries.ui.view.radius.RadiusTextView;
import com.chexiehui.jc.R;
import com.chexiehui.jc.base.BaseModel;
import com.chexiehui.jc.base.BaseMvpActivity;
import com.chexiehui.jc.mvp.mine.ChangePasswordCovenant;
import com.chexiehui.jc.mvp.mine.ChangePasswordPresenter;
import com.chexiehui.jc.utils.SoftKeyboardFixerForFullscreen;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @Description 修改密码
 * @Auth SongJun
 * @Date 2019/11/28 18:48
 **/
public class ChangePasswordActivity extends BaseMvpActivity<ChangePasswordPresenter> implements ChangePasswordCovenant.View {

    @BindView(R.id.et_old_password)
    EditText etOldPassword;
    @BindView(R.id.et_new_password)
    EditText etNewPassword;
    @BindView(R.id.rtv_save_submit)
    RadiusTextView rtvSaveSubmit;
    @BindView(R.id.et_again_password)
    EditText etAgainPassword;

    @Override
    protected int getLayout() {
        return R.layout.activity_change_password;
    }

    @Override
    protected void setTitleBar() {
        titleBar.setTitleMainText("修改密码");
    }

    @Override
    protected void initView(Bundle var1) {
        SoftKeyboardFixerForFullscreen.assistActivity(this);
    }

    @Override
    protected ChangePasswordPresenter createPresenter() {
        return new ChangePasswordPresenter(this);
    }

    @OnClick(R.id.rtv_save_submit)
    public void onViewClicked() {
        mvpPresenter.save();
    }

    @Override
    public void onSaveSuccess(BaseModel<Object> successResult) {
        showToast("密码修改成功");
        onBackPressed();
    }

    @Override
    public void onSaveFailure(BaseModel<Object> failureResult) {
        showToast("密码修改失败");
    }

    @Override
    public String getOldPassword() {
        return etOldPassword.getText().toString().trim();
    }

    @Override
    public String getNewPassword() {
        return etNewPassword.getText().toString().trim();
    }

    @Override
    public String getAgainPassword() {
        return etAgainPassword.getText().toString().trim();
    }

}